<?php

?>
	<aside id="banners">
        <h2>Google Ads</h2>
        <div id="banner1">
        <script type="text/javascript"><!--
            google_ad_client = "ca-pub-0021066091514957";
            /* Fawlty Towers 1 - 200x200 */
            google_ad_slot = "5937546315";
            google_ad_width = 200;
            google_ad_height = 200;
            //-->
        </script>
        <script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
        </div>
        <div id="banner2">
        <script type="text/javascript"><!--
            google_ad_client = "ca-pub-0021066091514957";
            /* Fawlty Towers 2 - 200x200 */
            google_ad_slot = "7288492536";
            google_ad_width = 200;
            google_ad_height = 200;
            //-->
        </script>
        <script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
        </div>
        
        <h2 id="fawlty-ads1">Fawlty Towers Ads</h2>
        <div id="banner3">
            <img src="img/local_ads_<?php echo rand(0,6); ?>.gif" width="200" height="130" alt="Local ad" />
        </div>
        
        <h2 id="fawlty-ads2">Happy Birthday <br /><i>(this month)</i></h2>
        <div id="banner4">
        	<?php
			
            if ($result = $mysqli->query("
											SELECT *
											FROM Actor
											WHERE 
												MONTH(dob)=MONTH(current_date())
											ORDER BY dod"
				)) 
				//MONTH(dob)=MONTH(current_date())
					{
						//$data = mysqli_fetch_array($result);
						
						//$dob = $data['dob'];
						//$dob = $data['dod'];
						
						//echo ">> ". count($data);
						
						while($obj = $result->fetch_object()) { 
							$id = $obj->id; 
							$actorName = $obj->actorName;
							$actorSurname = $obj->actorSurname; 
							$dob = $obj->dob;
							$dod = $obj->dod; 
							
							$date_array = explode("-", $dob);
							
							$year = (int) $date_array[0];
							$month = (int) $date_array[1];
							$day = (int) $date_array[2];
							
							$tyear = (int) date('Y');
							$tmonth = (int) date('n');
							$tday = (int) date('j');
							
							$todayStr = " this month.";
							$years = $tyear - $year - 1;
							if($tmonth > $month || ($tmonth == $month && $tday >= $day)) {
								++$years;
							}
							
							$divider = " is ";
							if ( $dod ) {
								$divider = " would of been ";
							}
							
							if ( $day == $tday ) {
								$todayStr = " today.";
							}
							
							?>
							<div id="dob"><a href="profile_actor.php?id=<?= $id; ?>"><?= $actorName; ?> <?= $actorSurname; ?></a> <?= $divider; ?> <?= $years.$todayStr; ?></div>
                            <?php
						}
					}
            ?>
        </div>
    </aside>